<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Controller extends CI_Controller {

    public $title="";
	public function __construct()
    {
        parent::__construct();
        $this->load->helper(array('url','convert','sql','date','menu'));
        $this->load->library(array('ckeditor','ckfinder','session','cart'));
        $this->ckeditor->basePath = base_url().'public/js/library/ckeditor/';
  		$this->ckeditor->config['toolbar'] = 'Full';
  		$this->ckeditor->config['language'] = 'vi';
  		$this->ckeditor->config['width'] = '99%';
  		$this->ckeditor->config['height'] = '200';
  		$this->ckfinder->SetupCKEditor($this->ckeditor);
  		$this->load->helper('ckeditor');
        $this->load->library('form_validation');
        $this->load->model('admin/product_model');
        $this->load->model('admin/category_product_model');
        $this->load->model('admin/article_model');
        $this->load->model('admin/menu_model');
        $menu_top=$this->menu_model->getMenuByPosition(1);
        $this->load->vars('menu_top',$menu_top);
        $menu_left=$this->menu_model->getMenuByPosition(2);
        $this->load->vars('menu_left',$menu_left);
    }
    public function doupload($field,$path)
    	{
    			$config['upload_path'] ='./public/upload/'.$path;
    			$config['allowed_types'] = 'gif|jpg|png|jpeg';
    			$config['max_size'] = 10000;
    			$config['max_width'] = 1366;
    			$config['max_height'] = 1000;
    			$this->load->library('upload', $config);
    			$this->upload->initialize($config);
    			$this->upload->do_upload($field);
    			$data_upload = $this->upload->data();
    			return $data_upload['file_name'];
    	}
}
